package com.agung.wonogirimaps;

import com.agung.wonogirimaps.util.Utils;
import com.google.android.gms.internal.ar;
import com.google.android.gms.maps.model.LatLng;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.net.Uri;
import android.os.Bundle;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class InfoHotelActivity extends ActionBarActivity implements
		OnClickListener
{
	private TextView	fasilitas, nomor, kelas, alamat;
	private ImageView	btnCall;
	private ImageView	btnDirection;
	private LatLng		location;
	private ImageView	imgThumb;
	String				nomor_telepon;
	private ImageLoader	imageLoader;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_info_hotel);

		imageLoader = ImageLoader.getInstance();
		imageLoader.init(Utils.getImgConfig(this));

		btnDirection = (ImageView) findViewById(R.id.btn_direct_hotel);
		imgThumb = (ImageView) findViewById(R.id.thumb_hotel);
		fasilitas = (TextView) findViewById(R.id.txt_info_fasilitas);
		nomor = (TextView) findViewById(R.id.txt_info_nomor_hotel);
		alamat = (TextView) findViewById(R.id.txt_info_alamat_hotel);
		kelas = (TextView) findViewById(R.id.txt_info_kelas_hotel);
		btnCall = (ImageView) findViewById(R.id.btn_call);
		btnCall.setOnClickListener(this);
		btnDirection.setOnClickListener(this);

		Bundle b = getIntent().getExtras();
		if (b != null)
		{

			getSupportActionBar().setTitle(b.getString(HotelActivity.TAG_NAMA));

			location = new LatLng(b.getDouble(HotelActivity.TAG_LAT),
					b.getDouble(HotelActivity.TAG_LNG));

			imageLoader.displayImage(b.getString(HotelActivity.TAG_GAMBAR),
					imgThumb, Utils.getImgOpt());

			fasilitas.setText(b.getString(HotelActivity.TAG_FASILITAS));

			nomor.setText(b.getString(HotelActivity.TAG_NOMOR_TELEPON));

			nomor_telepon = b.getString(HotelActivity.TAG_NOMOR_TELEPON);

			alamat.setText(b.getString(HotelActivity.TAG_ALAMAT));

			kelas.setText(b.getString(HotelActivity.TAG_KELAS));

		}

		getSupportActionBar().setIcon(android.R.color.transparent);

	}

	@Override
	public void onClick(View arg0)
	{
		// TODO Auto-generated method stub
		if (arg0 == btnCall)
		{
			Intent callIntent = new Intent(Intent.ACTION_CALL);
			callIntent.setData(Uri.parse("tel:" + nomor_telepon));
			startActivity(callIntent);

		} else if (arg0 == btnDirection)
		{
			Intent i = new Intent(android.content.Intent.ACTION_VIEW,
					Uri.parse("http://maps.google.com/maps?daddr="
							+ location.latitude + "," + location.longitude));
			startActivity(i);

		}

	}
}
